<script type="text/javascript" src="/media/js/ui/ui.tabs.js"></script>
<script type="text/javascript" src="/media/js/validate.js"></script>
<link href="/media/js/uploadify/uploadify.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="/media/js/uploadify/swfobject.js"></script>
<script type="text/javascript" src="/media/js/uploadify/jquery.uploadify.v2.1.4.min.js"></script>
<script type="text/javascript" src="/media/js/color/iColorPicker.js"></script>
<script type="text/javascript" src="/media/js/kindeditor/kindeditor-min.js"></script>
<script type="text/javascript">
    $(document).ready(function() {
        
        /****************编辑器 加载开始******************/
        var  content;
        KindEditor.ready(function(K) {
            content = K.create('#content');
        });
        /****************编辑器 加载结束******************/
        
        $('#tabs').tabs();
        // running ExColor
        
        $("#form").validate({
            rules:{
                title:'required',
                meta_url:'url',
                position:'number',
                views:'number'
            },
            messages:{
                title:'标题不能为空！',
                meta_url:'链接格式不对,请重新添加!格式如：http://www.xuwentec.com',
                position:'请添写正确的数字格式！',
                views:'请添写正确的数字格式！'
            },
            invalidHandler: function(e, validator) {
                var errors = validator.numberOfInvalids();
                if (errors) {
                    var message = errors == 1
                        ? '您有<font color="green">1</font>处填写错误,请认真填写！'
                    : '您有 <font color="green">' + errors + ' </font>处填写错误,请认真填写！';
                    $("div.error #error-info").html(message);
                    $('div.success').hide();
                    $("div.error").show();
                } else {
                    $("div.error").hide();
                }
            }
        });
        $('#custom_file_upload').uploadify({
            'uploader'       : '/media/js/uploadify/uploadify.swf',
            'script'         : '<?php echo URL::base()."admin/uploadify/images"; ?>',
            'cancelImg'      : '/media/js/uploadify/cancel.png',
            'folder'         : '/uploads/news',
            'multi'          : true,
            'auto'           : true,
            'fileExt'        : '*.jpg;*.gif;*.png',
            'fileDesc'       : 'Image Files (.JPG, .GIF, .PNG)',
            'queueID'        : 'custom-queue',
            'queueSizeLimit' : 300,
            'simUploadLimit' : 2,
            'removeCompleted': false,
            'displayData'   : 'shown',
            'scriptData': {"PHPSESSID":"<?php echo session_id();?>"},
            'onSelectOnce'   : function(event,data) {
                $('#status-message').text(data.filesSelected + ' files have been added to the queue.');
            },
            'onAllComplete'  : function(event,data) {
                $('#status-message').text(data.filesUploaded + ' files uploaded, ' + data.errors + ' errors.');
            }
        });	
    });

</script>

<div id="page-layout"><div id="page-content">
        <div id="page-content-wrapper">
            <div class="inner-page-title">
                <h2>新闻添加</h2>
            </div>
            <?php echo Message::get();?>
            <div class="response-msg error ui-corner-all" style="display:none;">
                <span>错误提示</span><span id="error-info"></span>
            </div>
            <div id="tabs">
                <ul>
                    <li><a href="#tabs-1">基本内容</a></li>
                    <li><a href="#tabs-2">新闻图片</a></li>
                </ul>
                <form action="" method="post" enctype="multipart/form-data" class="forms" name="form" id="form">
                    <div id="tabs-1">

                        <ul>
                            <li>
                                <label  class="desc"> 标题： <span class="req">*</span></label>
                                <div>
                                    <input type="text" id="title" tabindex="1" maxlength="255" value="" class="field text medium" name="title" />
                                    标题颜色：<input id="color" name="color" type="text" value="" class="iColorPicker" />
                                    &nbsp;&nbsp;是否加粗：<select name="strong">
								
									<option value="0" selected="selected">否</option>
									<option value="1">是</option>
									
									</select>
                                </div>
                            </li>

                            <li>
                                <label  class="desc"> 短标题： </label>
                                <div>
                                    <input type="text" tabindex="1" maxlength="255" value="" class="field text medium" name="subtitle" />
                                </div>
                            </li>
                            
                             <li>
                              <font style="font-weight: bold;color:#222222">所属分类：</font>
                                <select tabindex="3" class="field select small" name="id_category" > 
                                        <?php echo $news_categories;?>
                                </select>
                            </li>
                            <li>
                                <font style="font-weight: bold;color:#222222"> 作者：</font>
                                
                                <input type="text" tabindex="1" maxlength="255" value="" class="field text" name="author" />
                                
                                <font style="font-weight: bold;color:#222222"> 来源：</font>
                                
                                <input type="text" tabindex="1" maxlength="255" value="" class="field text small" name="source" />
                               
                            </li>
                            

                            <li>
                                <label  class="desc"> 链接： </label>
                                <div>
                                    <input type="text" tabindex="1" maxlength="255" value="" class="field text medium" name="meta_url" />
                                </div>
                            </li>
                            <li>
                                <font style="font-weight: bold;color:#222222">排序：</font> 

                                <input type="text" tabindex="1" maxlength="255" value="" class="field text" name="position" />

                                <font style="font-weight: bold;color:#222222">浏览次数：</font> 

                                <input type="text" tabindex="1" maxlength="255" value="" class="field text" name="views" />

                            </li>
                            <li>
                                <label  class="desc">
                                    简介：
                                </label>
                                <div>
                                    <textarea tabindex="2" cols="50" rows="5" class="field textarea small" name="description" ></textarea>
                                </div>
                            </li>

                            <li>
                                <label  class="desc">
                                    内容：
                                </label>
                                <div>
                                    <textarea tabindex="2" style="width:800px;height:300px;" class="field textarea small" name="content" id="content"></textarea>
                                </div>
                            </li>


                            <li>
                                <label  class="desc"> meta_title： </label>
                                <div>
                                    <input type="text" tabindex="1" maxlength="255" value="" class="field text medium" name="meta_title" />
                                </div>
                            </li>
                            <li>
                                <label  class="desc"> meta_keywords： </label>
                                <div>
                                    <input type="text" tabindex="1" maxlength="255" value="" class="field text medium" name="meta_keywords" />
                                </div>
                            </li>
                            <li>
                                <label  class="desc">
                                    meta_description：
                                </label>
                                <div>
                                    <textarea tabindex="2" cols="50" rows="5" class="field textarea small" name="meta_description" ></textarea>
                                </div>
                            </li>

                        </ul>
                    </div>
                    <div id="tabs-2">
                        <input id="custom_file_upload" type="file" name="Filedata" /> 
                        <div id="custom-queue"></div>

                    </div>
                    <ul>
                        <li class="buttons" style=" text-align: center;">
                            <button class="ui-state-default ui-corner-all ui-button" type="submit" id="submit_btn"> 添加新闻</button>
                        </li>
                    </ul>
                </form>
            </div>
            <div class="clearfix"></div>

<!--        <i class="note">* To see more boxes examples, like the ones above, visit for the menu, the Layout Options pages.</i>-->
            <?php echo View::factory('admin/content/content_left')->render(); ?>
            <div class="clear"></div>			
        </div>
        <div class="clear"></div>
    </div>
